package com.demo.core.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.demo.base.model.UserInfo;
import com.demo.core.dao.UserInfoDao;

@Transactional
@Service
public class UserInfoService {

	@Autowired
	private UserInfoDao userInfoDao;
	
	/**
	 * 添加用户
	 * @param userInfo
	 */
	public void addUserInfo(UserInfo userInfo){
		
		userInfoDao.add(userInfo);
	}
	
	/**
	 * 用户登录时查询用户是否存在
	 * @param loginName
	 * @param password
	 * @return
	 */
	public UserInfo userAuth(String loginName,String password,String password1){
		
		return userInfoDao.userAuth(loginName, password,password1);
	}
	
	/**
	 * 修改用户
	 * @param userInfo
	 */
	public void updateUserInfo(UserInfo userInfo){
		
		userInfoDao.update(userInfo);
	}
	
	/**
	 * 删除用户
	 * @param userInfo
	 */
	public void deleteUserInfo(UserInfo userInfo){
		
		userInfoDao.delete(userInfo);
	}
	
	/**
	 * 根据ID得到相应用户
	 * @param userId
	 * @return
	 */
	public UserInfo getUserInfo(String userId){
		
		return (UserInfo) userInfoDao.get(UserInfo.class, userId);
	}
}
